/**
 * 模板引擎
 * @param {String} html
 * @param {Object} options
 */
const templateEngine = function (html, options) {
  var re = /<%([^%>]+)?%>/g,
    reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g,
    code = 'var r=[];\n',
    cursor = 0;
  var add = function (line, js) {
    js ? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
      (code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');

    return add;
  }

  while (match = re.exec(html)) {
    add(html.slice(cursor, match.index))(match[1], true);
    cursor = match.index + match[0].length;
  }
  add(html.substr(cursor, html.length - cursor));
  code += 'return r.join("");';
  return new Function(code.replace(/[\r\t\n]/g, '')).apply(options);

}

const MODALS = {
  salers: data => {
    return templateEngine(`<div class="saledetail">
      <form class="form-horizontal" style="overflow: hidden;">
        <div class="col-sm-6 m-t-sm">
          <div class="form-group">
            <label for="salersName" class="col-sm-4 control-label necessary_front">商家名称</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="salersName" name="salersName"
                placeholder="必填" data-parsley-required data-parsley-trigger="change"
                value="<% this.name %>" <% this.readonly ? 'readonly' : '' %> />
            </div>
          </div>
        </div>
        <div class="col-sm-6 m-t-sm">
          <div class="form-group">
            <label for="salersNumber" class="col-sm-4 control-label necessary_front">YOMO号</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="salersNumber" name="salersNumber"
                placeholder="必填，没有时由运营负责帮助申请" data-parsley-required
                data-parsley-trigger="change" value="<% this.yomoCode %>" <% this.readonly ? 'readonly' : '' %>
              />
            </div>
          </div>
        </div>
        <div class="col-sm-12 m-t-sm">
          <div class="form-group">
            <label for="salersAdd" class="col-sm-2 control-label necessary_front">详细地址</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="salersAdd" name="salersAdd"
                placeholder="必填" data-parsley-required data-parsley-trigger="change"
                value="<% this.address %>" <% this.readonly ? 'readonly' : '' %> />
            </div>
          </div>
        </div>
        <div class="col-sm-12 m-t-sm">
          <div class="form-group">
            <label for="salersPhone" class="col-sm-2 control-label necessary_front">联系方式</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="salersPhone" name="salersPhone"
                placeholder="必填" data-parsley-required data-parsley-trigger="change"
                value="<% this.tel %>" <% this.readonly ? 'readonly' : '' %> />
            </div>
          </div>
        </div>
        <div class="col-sm-12 m-t-sm">
          <div class="form-group">
            <label for="salersOtherInfo" class="col-sm-2 control-label">说明</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="salersOtherInfo"
                name="salersOtherInfo" placeholder="对商家的一些其他描述" value="<% this.explain %>" <% this.readonly ? 'readonly' : '' %>
              />
            </div>
          </div>
        </div>
      </form>
    </div>`, data);
  },
  redbags: data => {
    return templateEngine(`<div class="cashDispatch">
    <form class="form-horizontal" style="overflow: hidden;">
      <div class="col-sm-6 m-t-sm" style="display:<% this.visibility ? 'block' : 'none' %>">
        <div class="form-group">
          <label for="voucherChoose" class="col-sm-4 control-label necessary_front">选择代金券</label>
          <div class="col-sm-8">
            <select class="form-control" id="voucherChoose" name="voucherChoose"
              data-parsley-required data-parsley-trigger="change"
              value="<% this.voucher %>">
              <option value=""></option>
              <option value="0">满200-100</option>
              <option value="1">满300-100</option>
              <option value="2">满500-100</option>
            </select>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="totalMoney" class="col-sm-4 control-label necessary_front"><% this.firstTitle %></label>
          <div class="col-sm-8">
            <input type="text" data-parsley-type="number" class="form-control"
              id="totalMoney" name="totalMoney" placeholder="<% this.firstPlace %>"
              data-parsley-required data-parsley-trigger="change"
              value="<% this.totalMoney %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm" style="display:<% this.hidden %>">
        <div class="form-group">
          <label for="totalNumber" class="col-sm-4 control-label necessary_front"><% this.secondTitle %></label>
          <div class="col-sm-8">
            <input type="text" data-parsley-type="integer" class="form-control"
              id="totalNumber" name="totalNumber" placeholder="<% this.secondPlace %>"
              data-parsley-required data-parsley-trigger="change"
              value="<% this.totalNumber %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="limitSex" class="col-sm-4 control-label necessary_front">限制条件</label>
          <div class="col-sm-8">
            <select class="form-control" id="limitSex" name="limitSex"
              data-parsley-required data-parsley-trigger="change">
              <option value=""></option>
              <option value="0" <% this.limitSex === '0' ? 'selected' : '' %>>都可领取</option>
              <option value="1" <% this.limitSex === '1' ? 'selected' : '' %>>男生可领</option>
              <option value="2" <% this.limitSex === '2' ? 'selected' : '' %>>女生可领</option>
            </select>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="getRange" class="col-sm-4 control-label necessary_front">可领范围</label>
          <div class="col-sm-8">
            <input type="text" data-parsley-type="number" class="form-control"
              id="getRange" name="getRange" placeholder="必填"
              data-parsley-required data-parsley-trigger="change"
              value="<% this.getRange %>" />
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <div class="m-l-md">
        <span class=" h5 text-danger m-l-xs">可见范围</span>
        <div class="line line-dashed"></div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="longitudeS" class="col-sm-4 control-label necessary_front">经度</label>
          <div class="col-sm-8">
                <input type="text" data-parsley-type="number" id="longitudeS"
                  class="form-control" name="longitudeS"
                  min="-180" max="180" data-parsley-required data-parsley-trigger="change"
                  value="<% this.longitudeS %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="latitudeS" class="col-sm-4 control-label necessary_front">纬度</label>
          <div class="col-sm-8">
                <input type="text" data-parsley-type="number" id="latitudeS"
                  class="form-control" name="latitudeS"
                  min="-90" max="90" data-parsley-required data-parsley-trigger="change"
                  value="<% this.latitudeS %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="latitudeS" class="col-sm-4 control-label necessary_front">文本地址</label>
          <div class="col-sm-8">
                <input type="text" data-parsley-type="number" id="latitudeS"
                  class="form-control" name="location" data-parsley-required data-parsley-trigger="change"
                  value="<% this.location %>" />
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <div class="line line-dashed m-l-md"></div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="proPic" class="col-sm-4 control-label necessary_front">添加宣传图</label>
          <div class="col-sm-5">
            <input type="button" id="proPic" class="text-center form-control btn-s btn-primary necessary_front"
              value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="[name=pic]"
            />
            <input type="hidden" name="pic" data-parsley-required data-parsley-trigger="change"
              value="<% this.pic %>">
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="pageUrl" class="col-sm-4 control-label necessary_front">添加h5链接</label>
          <div class="col-sm-5">
            <input type="text" data-parsley-type="url" id="pageUrl" class="form-control"
              name="pageUrl" data-parsley-required data-parsley-trigger="change"
              value="<% this.pageUrl %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-12 m-t-sm">
        <div class="form-group">
          <label for="otherInfo" class="col-sm-2 control-label">说明</label>
          <div class="col-sm-10">
            <textarea id="otherInfo" name="otherInfo" class="form-control"
              rows="3" data-parsley-required data-parsley-trigger="change"><% this.otherInfo %></textarea>
          </div>
        </div>
      </div>
    </form>
  </div>`, data);
  },
  bagCollectedDetail: data => {
    return templateEngine(`<div class="redbagdetail">
    <section class="panel panel-default m-b-none">
      <div class="row m-l-none m-r-none bg-light text-center">
        <div class="col-sm-4 padder-v b-r b-light">
          <a class="clear" href="#">
            <span class="h4 block">总数</span>
            <span class="h2 block m-t-xs text-danger">
              <strong></strong>
            </span>
            <small class="text-muted text-uc">个</small>
          </a>
        </div>
        <div class="col-sm-4 padder-v b-r b-light">
          <a class="clear" href="#">
            <span class="h4 block">已领取</span>
            <span class="h2 block m-t-xs text-danger">
              <strong></strong>
            </span>
            <small class="text-muted text-uc">个</small>
          </a>
        </div>
        <div class="col-sm-4 padder-v b-r b-light">
          <a class="clear" href="#">
            <span class="h4 block">剩余</span>
            <span class="h2 block m-t-xs text-danger">
              <strong></strong>
            </span>
            <small class="text-muted text-uc">个</small>
          </a>
        </div>
      </div>
    </section>
    <div class="panel-body">
    <form class="form-inline queryForm gcForm">
    <input type="hidden" id="currentPage" name="page">
    <input type="hidden" name="userId" value="$!userId">
    <input type="hidden" id="status" name="status" value="$status">
    <input type="hidden" id="date11" name="date11" value="$date11">
    <input type="hidden" id="date22" name="date22" value="$date22">
    <div class="form-group">
      <input type="text" class="form-control m-r-md" name="queryCriteria"
        value="$!queryCriteria" placeholder="输入用户名或账号">
      <label for="apply_start_date">起止日期：</label>
      <input type="date" value="$date11" id="apply_start_date" class="form-control"
        name="apply_start_date" readonly/>
      <label for="apply_end_date">-</label>
      <input type="date" value="$date22" id="apply_end_date" class="form-control"
        name="apply_end_date" readonly/>
    </div>
    <button type="submit" class="btn btn-success m-l-md">查询</button>
    <span class="btn btn-sm btn-rounded btn-primary pull-right m-l-md"
      onclick="">导出</span>
    </form>
      <div data-gctable>
        <div style="min-width:700px;">
          <table>
            <thead>
              <tr>
                <th width="15%">用户头像</th>
                <th width="25%">用户账号</th>
                <th width="20%">用户昵称</th>
                <th width="20%">领取金额（个数）</th>
                <th>领取时间</th>
              </tr>
            </thead>
          </table>
        </div>
        <div class="gcBody" style="min-width:700px;">
          <table>
            <tbody class="gcData">
              <tr class="bg-white" data-id="">
                <td width="15%">
                  <img src="" onclick="imgMagnify($(this).attr('src'))">
                </td>
                <td width="25%"></td>
                <td width="20%"></td>
                <td width="20%"></td>
                <td></td>
              </tr>
              <%}%>
              <!-- 无数据时 -->
              <tr class="bg-white">
                <td colspan="5">暂无数据</td>
              </tr>
            </tbody>
          </table>
        </div>
        <p class="gcPage">
          #set ($formName = "salesForm") #parse('/html/page.html')
        </p>
      </div>
    </div>
  </div>`, data);
  },
  voucherCollectedDetail: data => {
    return templateEngine(`<div class="djqDetail">
    <section class="panel panel-default m-b-none">
        <div class="row m-l-none m-r-none bg-light text-center">
            <div class="col-sm-6 padder-v b-r b-light">
                <a class="clear" href="#">
                    <!-- 过期：已过期 || 未过期：待使用-->
                    <span class="h4 block"><% !this.status ? '已过期' : '待使用' %></span>
                    <span class="h2 block m-t-xs text-danger">
                        <strong><% this.unused %></strong>
                    </span>
                    <small class="text-muted text-uc">张</small>
                </a>
            </div>
            <div class="col-sm-6 padder-v b-r b-light">
                <a class="clear" href="#">
                    <span class="h4 block">已使用</span>
                    <span class="h2 block m-t-xs text-danger">
                        <strong><% this.used %></strong>
                    </span>
                    <small class="text-muted text-uc">张</small>
                </a>
            </div>
        </div>
    </section>
    <div class="panel-body">
        <form class="form-inline queryForm gcForm">
            <div class="form-group">
                <input type="text" class="form-control m-r-md" placeholder="输入用户名或账号">
                <label for="apply_start_date">起止日期：</label>
                <input type="text" id="apply_start_date" class="form-control"
                    name="apply_start_date" readonly/>
                <label for="apply_end_date">-</label>
                <input type="text" id="apply_end_date" class="form-control" name="apply_end_date"
                    readonly/>
            </div>
            <button type="submit" class="btn btn-success m-l-md">查询</button>
            <span class="btn btn-sm btn-rounded btn-primary pull-right m-l-md"
                onclick="JSONToCSVConvertor([{'商家名称': '第三方','注册时间' : '2012-12-12'},{'商家名称': '第三方','注册时间' : '2012-12-12'}], '商家列表.csv', true)">导出</span>
        </form>
        <div class="m-t-sm">
            <span class=" h5 text-danger m-l-xs">领取列表</span>
            <div class="line line-dashed"></div>
        </div>
        <div data-gctable>
            <div style="min-width:700px;">
                <table>
                    <thead>
                        <tr>
                            <th width="10%">用户头像</th>
                            <th width="15%">用户账号</th>
                            <th width="15%">用户昵称</th>
                            <th width="15%">领取个数</th>
                            <th width="15%">领取时间</th>
                            <th width="15%">使用时间</th>
                            <th>状态</th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="gcBody" style="min-width:700px;">
                <table>
                    <tbody class="gcData">
                    <%if(this.lists) {%>
                      <% for(var index in this.lists) {%>
                        <tr class="bg-white" data-id="">
                            <td width="10%">
                                <img src="<% this.lists[index].userPic %>" onclick="imgMagnify($(this).attr('src'))">
                            </td>
                            <td width="15%"><% this.lists[index].userNumber %></td>
                            <td width="15%"><% this.lists[index].userName %></td>
                            <td width="15%"><% this.lists[index].collectedMount %></td>
                            <td width="15%"><% this.lists[index].collectedTime %></td>
                            <td width="15%"><% this.lists[index].usedTime %></td>
                            <td><% this.lists[index].status %></td>
                        </tr>
                      <%}%>
                    <%} else {%>
                        <!-- 无数据时 -->
                        <tr class="bg-white">
                            <td colspan="7">暂无数据</td>
                        </tr>
                    <%}%>
                    </tbody>
                </table>
            </div>
            <p class="gcPage">
                #set ($formName = "salesForm") #parse('/html/page.html')
            </p>
        </div>
    </div>
</div>`, data);
  },
  identifyDetail: data => {
    return templateEngine(`<div class="identifydetail">
    <form class="form-horizontal">
      <input type="hidden" name="identifyId" value="<% this.identifyId %>">
      <input type="hidden" name="status">
      <div class="m-l-md m-t-sm">
        <span class=" h5 text-danger m-l-xs">认证信息</span>
        <div class="line line-dashed"></div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyMoney" class="col-sm-4 control-label">身份证号</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyMoney" readonly value="<% this.idCard %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">公司全称</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.companynameAll %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">联系人姓名</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.principalName %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">联系人电话</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.principalPhone %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">纳税人识别号</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.uniqueNumber %>" />
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">身份证</label>
          <div class="col-sm-8">
            <input type="button" id="proPic" class="text-center form-control btn-s btn-primary"
              value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="[data-name=idpic]" data-num="one"
            />
            <input type="hidden" data-name="idpic" value="<% this.idCardOssKey %>">
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyLicense" class="col-sm-4 control-label">营业执照</label>
          <div class="col-sm-8">
            <input type="button" id="identifyLicense" class="text-center form-control btn-s btn-primary"
              value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="[data-name=yypic]"
            />
            <input type="hidden" data-name="yypic" value="<% this.businessLicenseOssKey %>">
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <div class="m-l-md">
        <span class=" h5 text-danger m-l-xs">企业信息</span>
        <div class="line line-dashed"></div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">企业图片</label>
          <div class="col-sm-8">
            <input type="button" id="proPic" class="text-center form-control btn-s btn-primary"
              value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="[data-name=qypic]"
            />
            <input type="hidden" data-name="qypic" value="<% this.enterprisePic %>">
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyLicense" class="col-sm-4 control-label">企业logo</label>
          <div class="col-sm-8">
            <input type="button" id="identifyLicense" class="text-center form-control btn-s btn-primary"
              value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="[data-name=logopic]"
            />
            <input type="hidden" data-name="logopic" value="<% this.enterpriseLogo %>">
          </div>
        </div>
      </div>
      <div class="col-sm-12 m-t-sm">
        <div class="form-group">
          <label for="otherInfo" class="col-sm-2 control-label">企业简介</label>
          <div class="col-sm-10">
            <textarea id="otherInfo" class="form-control"
              rows="3" readonly><% this.introduction %></textarea>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">企业职位</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.position %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">企业名称</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.companyName %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">地址</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.address %>" />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="identifyPerson" class="col-sm-4 control-label">联系电话</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="identifyPerson" readonly
              value="<% this.contactPhone %>" />
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <!-- 以下两项审核页面可见 -->
      <div class="examine" style="display:none;">
        <div class="line line-dashed"></div>
        <div class="col-sm-4 m-t-sm">
          <div class="form-group">
            <label class="col-sm-4 control-label">审核结果</label>
            <div class="col-sm-8">
              <select class="form-control result" data-parsley-required data-parsley-trigger="change" value="<% this.status %>">
                <option value=""></option>
                <option value="1">审核通过</option>
                <option value="2">审核不通过</option>
              </select>
              <input type="text" class="form-control resultText" readonly
              value="<% this.status == 1 ? '待审核' : (this.status == 2 ? '审核通过' : '审核不通过')%>" style="display:none;"/>
            </div>
          </div>
        </div>
        <div class="col-sm-12 m-t-sm opinion">
          <div class="form-group">
            <label class="col-sm-1 control-label" style="padding:7px 0;">审核意见</label>
            <div class="col-sm-11">
              <textarea name="remark" class="form-control opinionTxt" rows="3" ><% this.remark %></textarea>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>`, data);
  },
  balanceDetail: data => {
    return templateEngine(`<div class="balancedetail">
    <div class="panel-body">
      <form class="form-inline queryForm gcForm">
        <div class="form-group">
          <label for="apply_start_date">起止日期：</label>
          <input type="text" id="apply_start_date" class="form-control"
            name="apply_start_date" readonly/>
          <label for="apply_end_date">-</label>
          <input type="text" id="apply_end_date" class="form-control" name="apply_end_date"
            readonly/>
        </div>
        <button type="submit" class="btn btn-success m-l-md">查询</button>
        <span class="btn btn-sm btn-rounded btn-primary pull-right m-l-md"
          onclick="JSONToCSVConvertor([{'商家名称': '第三方','注册时间' : '2012-12-12'},{'商家名称': '第三方','注册时间' : '2012-12-12'}], '商家列表.csv', true)">导出</span>
      </form>
      <div data-gctable>
        <div style="min-width:700px;">
          <table>
            <thead>
              <tr>
                <th width="20%">产生时间</th>
                <th width="30%">金额</th>
                <th width="30%">当前余额</th>
                <th>类型</th>
              </tr>
            </thead>
          </table>
        </div>
        <div class="gcBody" style="min-width:700px;">
          <table>
            <tbody class="gcData">
                <%if(this.arrs) {%>
                  <% for(var index in this.arrs) {%>
                    <tr class="bg-white" data-id="">
                      <td width="20%">
                        <% this.arrs[index].date %>
                      </td>
                      <td width="30%">
                        <% this.arrs[index].mount %>
                      </td>
                      <td width="30%">
                        <% this.arrs[index].rest %>
                      </td>
                      <td>
                        <% this.arrs[index].type %>
                      </td>
                    </tr>
                    <%}%>
                <%} else {%>
                <!-- 无数据时 -->
                <tr class="bg-white">
                  <td colspan="4">暂无数据</td>
                </tr>
                <%}%>
            </tbody>
          </table>
        </div>
        <p class="gcPage">
          #set ($formName = "salesForm") #parse('/html/page.html')
        </p>
      </div>
    </div>
  </div>`, data);
  },
  redDetail: data => {
    return templateEngine(`<div class="cashDispatch">
    <form class="form-horizontal" id="redForm" style="overflow: hidden;"
      method="post" enctype="multipart/form-data">
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="voucherChoose" class="col-sm-4 control-label necessary_front">选择红包类型</label>
          <div class="col-sm-8">
            <select class="form-control" name="redType" id="redType" data-parsley-required
              data-parsley-trigger="change" <% this.readonly ? 'disabled' : '' %>>
              <option value=""></option>
              <option value="0" <% this.redType === 0 ? 'selected' : '' %>>现金红包</option>
              <option value="21" <% this.redType === 21 ? 'selected' : '' %>>代金券红包</option>
              <option value="22" <% this.redType === 22 ? 'selected' : '' %>>精灵豆红包</option>
            </select>
          </div>
        </div>
      </div>

      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="address" class="col-sm-4 control-label necessary_front">
            文本地址
          </label>
          <div class="col-sm-8">
            <input type="text" id="address" class="form-control" name="address" value="<% this.address %>" <% this.readonly ? 'readonly' : '' %>/>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="longitude" class="col-sm-4 control-label necessary_front">
            经度
          </label>
          <div class="col-sm-8">
            <input type="text" id="longitude" class="form-control" name="longitude" value="<% this.longitude %>" <% this.readonly ? 'readonly' : '' %>/>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="latitude" class="col-sm-4 control-label necessary_front">
            纬度
          </label>
          <div class="col-sm-8">
            <input type="text" class="form-control" id="latitude" name="latitude" value="<% this.latitude %>" <% this.readonly ? 'readonly' : '' %>/>
          </div>
        </div>
      </div>

      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="ReceiveRequire" class="col-sm-4 control-label necessary_front">限制条件</label>
          <div class="col-sm-8">
            <select class="form-control" id="ReceiveRequire" name="ReceiveRequire"
              data-parsley-required data-parsley-trigger="change" <% this.readonly ? 'disabled' : '' %>>
              <option value='0' <% this.ReceiveRequire === 0 ? 'selected' : '' %>>全部可领取</option>
              <option value='1' <% this.ReceiveRequire === 1 ? 'selected' : '' %>>仅"男"可领取</option>
              <option value='2' <% this.ReceiveRequire === 2 ? 'selected' : '' %>>仅"女"可领取</option>
            </select>
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="receiveRange" class="col-sm-4 control-label necessary_front">可领取范围</label>
          <div class="col-sm-8">
            <input type="text" data-parsley-type="number" min="1" class="form-control"
              id="receiveRange" name="receiveRange" placeholder="可领取范围需大于等于1"
              data-parsley-required data-parsley-trigger="change" value="<% this.receiveRange %>" <% this.readonly ? 'readonly' : '' %>
            />
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
      <div class="m-l-md">
        <span class=" h5 text-danger m-l-xs">红包详情</span>
        <div class="line line-dashed"></div>
      </div>
      <div class="redDetail">
        <div class="col-sm-6 m-t-sm">
          <div class="form-group">
            <label for="redAmount" class="col-sm-4 control-label necessary_front">
              <% this.redType === 0 ? '红包总金额' : (this.redType === 21 ? '选择代金券' : '精灵豆总个数')%>
            </label>
            <div class="col-sm-8">
              <input type="text" data-parsley-type="number" min="0.1" class="form-control"
                id="redAmount" name="redAmount" placeholder="需大于等于0.1"
                data-parsley-required data-parsley-trigger="change" value="<% this.redType === 0 ? this.redAmount : (this.redType === 21 ? this.voucher : this.legumes)%>" <% this.readonly ? 'readonly' : '' %>
              />
            </div>
          </div>
        </div>
        <div class="col-sm-6 m-t-sm">
          <div class="form-group">
            <label for="redNum" class="col-sm-4 control-label necessary_front">
              <% this.redType === '21' ? '代金券总张数' : '总人数' %>
            </label>
            <div class="col-sm-8">
              <input type="text" data-parsley-type="integer" min="1" class="form-control"
                id="redNum" name="redNum" placeholder="总金额/总人数需大于等于0.1"
                data-parsley-required data-parsley-trigger="change" value="<% this.redNum %>" <% this.readonly ? 'readonly' : '' %>
              />
            </div>
          </div>
        </div>

      </div>
      <div class="clearfix"></div>
      <div class="line line-dashed m-l-md"></div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="proPic" class="col-sm-4 control-label necessary_front">添加宣传图</label>
          <div class="col-sm-5">
            <input type="button" id="proPic" class="text-center form-control btn-s btn-primary necessary_front"
            value="<% this.readonly ? '查看图片' : '上传图片' %>" data-upload="image" data-input="#xct"
            />
            <input style="display:none;" multiple type="file" name="redClue"
              class="gc_upload_input" data-input="#xct">
            <input type="hidden" id="xct" data-parsley-required data-parsley-trigger="change" value="<% this.xct %>"
            />
          </div>
        </div>
      </div>
      <div class="col-sm-6 m-t-sm">
        <div class="form-group">
          <label for="redURL" class="col-sm-4 control-label">添加h5链接</label>
          <div class="col-sm-5">
            <input type="text" data-parsley-type="url" id="redURL" class="form-control" value="<% this.redURL %>"
              name="redURL" <% this.readonly ? 'readonly' : '' %>/>
          </div>
        </div>
      </div>
      <div class="col-sm-12 m-t-sm">
        <div class="form-group">
          <label for="remark" class="col-sm-2 control-label">说明</label>
          <div class="col-sm-10">
            <textarea id="remark" name="remark" class="form-control" rows="3" <% this.readonly ? 'readonly' : '' %>><% this.remark %></textarea>
          </div>
        </div>
      </div>
    </form>
  </div>`, data);
  }
}